package com.wie.staffhubpro.controller;

import com.wie.staffhubpro.BaseContext.BaseContext;
import com.wie.staffhubpro.domain.entity.Result;
import com.wie.staffhubpro.domain.entity.User;
import com.wie.staffhubpro.domain.vo.UserVO;
import com.wie.staffhubpro.service.UserService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Slf4j
@CrossOrigin
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 获取当前用户信息
     */
    @GetMapping("/getUserInfo")
    public Result getUserInfo () {
        log.info("获取当前用户信息");
        Integer userId = BaseContext.getCurrentId();
        UserVO userVO = userService.getUserInfo(userId);
        return Result.success(userVO);
    }

}
